define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope,Share,GoDialog,GoPage) {
		$scope.scope = new Object();
		var checked = new Array();
		$scope.init_data = function() {
			Share.shared_list(function(data) {
				$scope.datas = data.sharetype;
			})
		}
		$scope.submit = function() {
			//获取被选中的id

			for(var i = 0; i < $scope.datas.length; i++) {
				if($scope.datas[i].checked == true) {
					var n = checked.length;
					checked[n] = {
						"id": $scope.datas[i].id
					};
				}
			}
			if(checked.length > 0) {
				console.log(checked);
				Share.shared_submit(checked, function(data) {
					if(data.success == true) {
						GoDialog.toast('分享成功');
						GoPage.go_states("t-set");//页面跳转
						
					} else
						GoDialog.toast('分享失败');
						checked = new Array();
				})
			} else {
				GoDialog.toast('请选择分享类型');
			}
		}
		$scope.init_data();
	}

	controller.$inject = ['$scope', 'Share','GoDialog','GoPage'];

	return app.registerController("sharectrl",controller);
});